/**
 * Author:yuiop
 * Date:2022/11/24 20:50
 */
package com.devops.admin.graphql;

import com.devops.admin.model.Stock;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsSubscription;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;

import java.time.Duration;

@DgsComponent
public class SubscriptionDataFetcher {
    @DgsSubscription
    public Publisher<Stock> stocks() {
        return Flux.interval(Duration.ofSeconds(0),Duration.ofSeconds(1))
                .map(t -> Stock.builder().name("lpc").price(500 + t).build());
    }
}
